<?php 
if (!$GET_service || $GET_service != "getusuarios") {
	die("<script>window.location='../?'</script>");
}

if (!isset($_SESSION['loggeduser']) || $_SESSION['loggeduser']['id'] == "") {
	die("<script>window.location='./?'</script>");
}
header('Content-Type: text/json; charset=UTF-8');

$db->begin();
$result = $db->select("SELECT usu_id, usu_username, usu_firstname, usu_lastname FROM usuario");

if ($result) {
	$usuarios = array();
	while($linha = mysql_fetch_array($result, MYSQLI_ASSOC)){
		array_push($usuarios, $linha);
	}
		
	//die(is_array($setor));
	die(json_encode($usuarios));
} else {
	die(json_encode(Array("estado" => "ERRO")));
}	
?>